//
//  MTPlayGroundVC.m
//  met
//
//  Created by 李晓俊 on 2019/5/6.
//  Copyright © 2019 李晓俊. All rights reserved.
//

#import "MTPlayGroundVC.h"
#import "LLSegmentBarVC.h"
//关注
#import "MTPlayGroundFoucsVC.h"
//推荐
#import "MTPlayGroundSuggestVC.h"

@interface MTPlayGroundVC ()
@property (nonatomic,weak) LLSegmentBarVC * segmentVC;//

@end

@implementation MTPlayGroundVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self customNavItem];

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(pushCard) name:MTCardNotification2 object:nil ];
    
}
- (void)pushCard {
   
}
- (void)CreateNav {
    
}
- (LLSegmentBarVC *)segmentVC{
    if (!_segmentVC) {
        LLSegmentBarVC *vc = [[LLSegmentBarVC alloc]init];
        // 添加到到控制器
        [self addChildViewController:vc];
        _segmentVC = vc;
    }
    return _segmentVC;
}
#pragma mark - 定制导航条内容
- (void) customNavItem {
//    self.navigationItem.title = @"消息";
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    self.navigationController.navigationBar.barTintColor = KBlackColor;
    //    // 1 设置segmentBar的frame
        self.segmentVC.segmentBar.frame = CGRectMake(100, 0, kScreenWidth-200, 35);
        self.navigationItem.titleView = self.segmentVC.segmentBar;
    
    
        // 2 添加控制器的View
        self.segmentVC.view.frame = self.view.bounds;
        [self.view addSubview:self.segmentVC.view];
        NSArray *items = @[@"关注", @"推荐"];
        MTPlayGroundFoucsVC *follow = [[MTPlayGroundFoucsVC alloc] init];
        MTPlayGroundSuggestVC *find = [[MTPlayGroundSuggestVC alloc] init];
        // 3 添加标题数组和控住器数组
        [self.segmentVC setUpWithItems:items childVCs:@[follow,find]];
        // 4  配置基本设置  可采用链式编程模式进行设置
        [self.segmentVC.segmentBar updateWithConfig:^(LLSegmentBarConfig *config) {
            config.itemNormalColor(KBlackColor).itemSelectColor(KBlackColor).indicatorColor(KBlackColor).indicatorExtraW(5).indicatorHeight(3).itemFont(CLRudeCircleTextFont(15));
        }];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [WRNavigationBar wr_setDefaultNavBarBarTintColor:KWhiteColor];

//    [WRNavigationBar wr_setDefaultNavBarShadowImageHidden:NO];
    //只创建一次
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    NSString *playground = [userDefault objectForKey:@"playground"];
    if ([playground isEqualToString:@"1"]) {

    }else {
        NSUserDefaults *dataUser = [NSUserDefaults standardUserDefaults];
        [dataUser setObject:@"1" forKey:@"playground"];
        [dataUser synchronize];
        
        MTOkTishiView *okView = [[MTOkTishiView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
        okView.content.text = @"欢迎来到广场～\n这里是创意家聚集地\n广场回答对问题 不可加好友\n而且只可以回答一次哟";
        okView.bgView.backgroundColor = KMainColor;
        okView.goButClick = ^(NSString *  s) {
            
        };
        [[UIApplication sharedApplication].keyWindow addSubview:okView];
    }
}

@end
